Skip to content

Refactor of particle initialisation - #33

Open
Carpenteri0 wants to merge 19 commits into
iterorganization:developfrom
Carpenteri0:feature/init-refactor
Open

Carpenteri0 wants to merge 19 commits into
iterorganization:developfrom
Carpenteri0:feature/init-refactor

Conversation

@Carpenteri0

Copy link
Copy Markdown
Collaborator

Mostly backend aesthetic changes. Main change is rejection functions have their own module, with type definitions, a few helper subroutines, and all existing rej funcs that were previously in ~3 other modules. Other smaller changes :

  • Removed num_re param. Now rep and epf both use n_particles_total to set weights
  • Reduced code duplication in 3 initialiser subroutines - evaluation of rej f now has its own subroutine in the rej f module
  • Initialiser function is checked against particle type rather than coupling scheme - more flexibility / reuseability in initialiser subroutines between coupling schemes.
  • Removed hard coded current limits in current_pdf - now finds these limits once per run before initialisation
  • Also added Timo's "experimental" method of initialising particles in mod_import_experimental_dist (which is now moved to particles/initialisers/)

@N-Schwarz

Copy link
Copy Markdown
Collaborator

Hi @Carpenteri0 , you should be able to add reviewers to the pull request once it's ready.

@Carpenteri0

Carpenteri0 commented Sep 22, 2026 •

Copy link
Copy Markdown
Collaborator Author

Hi @Carpenteri0 , you should be able to add reviewers to the pull request once it's ready.

Hi @N-Schwarz , my apologies. I've added reviewers now. I think I've fixed the compile issues in the build tests, but as I don't have these issues with my setup, we'll have to wait for the tests to complete.

@Carpenteri0 Carpenteri0 reopened this Sep 22, 2026
Comment thread particles/diagnostics/mod_neutral_density.f90 Outdated
Comment thread particles/initialisers/mod_initialise_particles.f90
Comment thread models/phys_module.f90

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Old RE inputs that still set num_re will now fail at namelist read with a generic error. It would be worth a line pointing to n_particles_total

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed num_re in the only .md where it turned up, and the reg_tests. Hopefully any RE people already using kinetic_main will notice this change, where else would you suggest leaving a comment?

zj_lo = 1.d10; zj_hi = -1.d10
R_lo = 1.d10; R_hi = -1.d10

do i_elm = 1, element_list%n_elements

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jzmin/jzmax now come from the whole domain. Can it go <0 ? If we are not sure it's better to cap it to 0?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Current can go either way in the tokamak, right? I guess usually it is largely in one direction, but in general I don't think there is anything physical prohibiting regions of opposing current. Ie jz can be both positive and negative at different points for the same time.

@Carpenteri0

Copy link
Copy Markdown
Collaborator Author

Hi @N-Schwarz , @Daniel-Maris . I've addressed @edo01 comments now, have you had a chance to take a look at this PR? I believe its ready (and significantly cleans up the previous state of initialising EPs/REs in kinetic_main)

@Carpenteri0

Copy link
Copy Markdown
Collaborator Author

Quick comments from Daniel after chat in Culham (for bookeeping).

  1. Rename filenames in particles/initialisers/ to be more descriptive
  2. Can move RE_gaussian into intialisers_base
  3. Standard naming format for initialiser functions

^^ Only really naming changes, but atm not obvious at all, this PR is probably the best place to make these name changes.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants